<template>
  <div>
    <van-tabs v-model="active" @click="onClick">
      <van-tab v-for="index in brotherCategory" :key="index.id" :title="index.name">  
      </van-tab>
    </van-tabs>
     <tabData 
     :id='id'
     :brotherCategory='brotherCategory'
     />
  </div>
</template>

<script>
import tabData from '@/components/navTab/tabData.vue'
import {GetGoodsCategory} from '@/request/api'
import { Toast } from "vant";
export default {
  name: "H559Tabnav",

  components: {
    tabData
  },

  directives: {},

  data() {
    return {
      active:0,
      id:'',
      brotherCategory:'',
      classid:'',
      name:'zhangsan'
    };
  },

  mounted() {},

  methods: {
    onClick(k){
      for(let i=0;i<this.brotherCategory.length;i++){
        if(k==i){
          this.id=this.brotherCategory[i].id
          // console.log(this.id);
        }
      }
        Toast.loading({
        message: "加载中...",
        duration: 400,
        forbidClick: true,
      });
    }
  },
  created(){
    this.id=this.$route.query.id
    GetGoodsCategory({id:this.id}).then(res=>{
      // console.log(res);
      this.brotherCategory=res.data.brotherCategory;
      // console.log(this.brotherCategory);
      for(let i=0;i<this.brotherCategory.length;i++){
        if(this.id==this.brotherCategory[i].id){
          
          this.active=i
        }
        
      }
      
    })
  }
};
</script>

<style lang="less" scoped>
</style>